package com.zk.mylib

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zk.mylib.ui.activity.*
import com.zk.mylib.ui.activity.fragment.FragmentExample2Activity
import com.zk.mylib.ui.activity.fragment.FragmentExampleActivity

/**
 * UI主页面
 */
class MainUIActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main_ui)
        var recyclerView = findViewById<RecyclerView>(R.id.recyclerview)
        recyclerView.layoutManager=LinearLayoutManager(this)
        var datas= mutableListOf("侧边栏菜单滑动DrawLayout","MotionLayout动画一","MotionLayout轨迹动画二","MotionLayout图片切换3",
            "ImageFilterView","图片动画MotionLayout、ImageFilterView","吸顶MotionLayout、CoordinatorLayout","侧滑吸顶DrawerLayout、MotionLayout、CoordinatorLayout",
            "SidePanel MotionLayout","MotionLayout、Tablayout、ViewPager","MotionLayout、Coordination","MotionLayout、Reveal",
            "MotionLayout、ViewPager、Lottie","MotionLayout Keytrigger","MotionLayout multistate","上拉拖动","拖动控件"
            )
        var homeAdapter = HomeAdapter(datas)
        homeAdapter.setOnItemClickListener { adapter, _, position ->
            var item = adapter.getItem(position) as String
            if(item=="侧边栏菜单滑动DrawLayout"){
                startActivity(Intent(this@MainUIActivity, DrawerLayoutActivity::class.java))

            }else if(item=="MotionLayout动画一"){
                startActivity(Intent(this@MainUIActivity, MotionLayout1Activity::class.java))
            }else if(item=="ImageFilterView"){
                startActivity(Intent(this@MainUIActivity, ImageFilterViewActivity::class.java))
            }else if(item=="MotionLayout轨迹动画二"){
                startActivity(Intent(this@MainUIActivity, MotionLayout2Activity::class.java))
            }else if(item=="图片动画MotionLayout、ImageFilterView"){
                startActivity(Intent(this@MainUIActivity, MotionLayout3Activity::class.java))
            }else if(item=="吸顶MotionLayout、CoordinatorLayout"){
                startActivity(Intent(this@MainUIActivity, MotionLayout4Activity::class.java))
            }else if(item=="侧滑吸顶DrawerLayout、MotionLayout、CoordinatorLayout"){
                startActivity(Intent(this@MainUIActivity, MotionLayout5Activity::class.java))
            }else if(item=="SidePanel MotionLayout"){
                startActivity(Intent(this@MainUIActivity, MotionLayout6Activity::class.java))
            }else if(item=="MotionLayout图片切换3"){
                startActivity(Intent(this@MainUIActivity, MotionLayout7Activity::class.java))
            }else if(item=="MotionLayout、Tablayout、ViewPager"){
                startActivity(Intent(this@MainUIActivity, MotionLayout8Activity::class.java))
            }else if(item=="MotionLayout、Coordination"){
                startActivity(Intent(this@MainUIActivity, MotionLayout9Activity::class.java))
            }else if(item=="MotionLayout、Reveal"){
                startActivity(Intent(this@MainUIActivity, MotionLayout10Activity::class.java))
            }else if(item=="MotionLayout、ViewPager、Lottie"){
                startActivity(Intent(this@MainUIActivity, MotionLayout11Activity::class.java))
            }else if(item=="MotionLayout Keytrigger"){
                startActivity(Intent(this@MainUIActivity, FragmentExampleActivity::class.java))
            }else if(item=="MotionLayout multistate"){
                startActivity(Intent(this@MainUIActivity, FragmentExample2Activity::class.java))
            }else if(item=="上拉拖动"){
                startActivity(Intent(this@MainUIActivity, MotionLayout14Activity::class.java))
            }else if(item=="拖动控件"){
                startActivity(Intent(this@MainUIActivity, DragViewActivity::class.java))
            }


        }
        recyclerView.adapter=homeAdapter


    }
    class HomeAdapter( mutableList: MutableList<String>) : BaseQuickAdapter<String,BaseViewHolder>(R.layout.view_item_home,mutableList) {
        override fun convert(holder: BaseViewHolder, item: String) {
           holder.setText(R.id.tv_title,item)
        }

    }
}